{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## The Dataset:\n",
    "Titanic Data Set from Kaggle: https://www.kaggle.com/c/titanic. \n",
    "\n",
    "The data has been split into two groups:\n",
    "- training set (train.csv)\n",
    "- test set (test.csv)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Data Dictionary\n",
    "\n",
    "- **PassegerId:** numeric\n",
    "- **Survived:**\t0 = No, 1 = Yes\n",
    "- **Pclass:**\t1 = 1st, 2 = 2nd, 3 = 3rd\n",
    "- **Name:**     text\n",
    "- **sex:**      male or female\t\n",
    "- **Age:**\t    numeric\t\n",
    "- **SibSp:**\t# of siblings / spouses aboard the Titanic (numeric)\t\n",
    "- **Parch:**\t# of parents / children aboard the Titanic (numeric)\n",
    "- **Ticket:**\tTicket number (alphanumeric)\n",
    "- **Fare:**\t    Passenger fare (float)\n",
    "- **Cabin:**\tCabin number (alphanumeric)\n",
    "- **Embarked:**\tPort of Embarkation\tC = Cherbourg, Q = Queenstown, S = Southampton"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "import numpy as np\n",
    "import matplotlib.pyplot as plt\n",
    "%matplotlib inline"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "# read training data into a dataframe\n",
    "train = pd.read_csv('titanic_train.csv')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>PassengerId</th>\n",
       "      <th>Survived</th>\n",
       "      <th>Pclass</th>\n",
       "      <th>Name</th>\n",
       "      <th>Sex</th>\n",
       "      <th>Age</th>\n",
       "      <th>SibSp</th>\n",
       "      <th>Parch</th>\n",
       "      <th>Ticket</th>\n",
       "      <th>Fare</th>\n",
       "      <th>Cabin</th>\n",
       "      <th>Embarked</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>3</td>\n",
       "      <td>Braund, Mr. Owen Harris</td>\n",
       "      <td>male</td>\n",
       "      <td>22.0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>A/5 21171</td>\n",
       "      <td>7.2500</td>\n",
       "      <td>NaN</td>\n",
       "      <td>S</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>Cumings, Mrs. John Bradley (Florence Briggs Th...</td>\n",
       "      <td>female</td>\n",
       "      <td>38.0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>PC 17599</td>\n",
       "      <td>71.2833</td>\n",
       "      <td>C85</td>\n",
       "      <td>C</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>3</td>\n",
       "      <td>1</td>\n",
       "      <td>3</td>\n",
       "      <td>Heikkinen, Miss. Laina</td>\n",
       "      <td>female</td>\n",
       "      <td>26.0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>STON/O2. 3101282</td>\n",
       "      <td>7.9250</td>\n",
       "      <td>NaN</td>\n",
       "      <td>S</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>4</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>Futrelle, Mrs. Jacques Heath (Lily May Peel)</td>\n",
       "      <td>female</td>\n",
       "      <td>35.0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>113803</td>\n",
       "      <td>53.1000</td>\n",
       "      <td>C123</td>\n",
       "      <td>S</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   PassengerId  Survived  Pclass  \\\n",
       "0            1         0       3   \n",
       "1            2         1       1   \n",
       "2            3         1       3   \n",
       "3            4         1       1   \n",
       "\n",
       "                                                Name     Sex   Age  SibSp  \\\n",
       "0                            Braund, Mr. Owen Harris    male  22.0      1   \n",
       "1  Cumings, Mrs. John Bradley (Florence Briggs Th...  female  38.0      1   \n",
       "2                             Heikkinen, Miss. Laina  female  26.0      0   \n",
       "3       Futrelle, Mrs. Jacques Heath (Lily May Peel)  female  35.0      1   \n",
       "\n",
       "   Parch            Ticket     Fare Cabin Embarked  \n",
       "0      0         A/5 21171   7.2500   NaN        S  \n",
       "1      0          PC 17599  71.2833   C85        C  \n",
       "2      0  STON/O2. 3101282   7.9250   NaN        S  \n",
       "3      0            113803  53.1000  C123        S  "
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Show the first few rows of the dataframe\n",
    "train.head(4)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>PassengerId</th>\n",
       "      <th>Survived</th>\n",
       "      <th>Pclass</th>\n",
       "      <th>Age</th>\n",
       "      <th>SibSp</th>\n",
       "      <th>Parch</th>\n",
       "      <th>Fare</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>count</th>\n",
       "      <td>891.000000</td>\n",
       "      <td>891.000000</td>\n",
       "      <td>891.000000</td>\n",
       "      <td>714.000000</td>\n",
       "      <td>891.000000</td>\n",
       "      <td>891.000000</td>\n",
       "      <td>891.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>mean</th>\n",
       "      <td>446.000000</td>\n",
       "      <td>0.383838</td>\n",
       "      <td>2.308642</td>\n",
       "      <td>29.699118</td>\n",
       "      <td>0.523008</td>\n",
       "      <td>0.381594</td>\n",
       "      <td>32.204208</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>std</th>\n",
       "      <td>257.353842</td>\n",
       "      <td>0.486592</td>\n",
       "      <td>0.836071</td>\n",
       "      <td>14.526497</td>\n",
       "      <td>1.102743</td>\n",
       "      <td>0.806057</td>\n",
       "      <td>49.693429</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>min</th>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.420000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>25%</th>\n",
       "      <td>223.500000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>2.000000</td>\n",
       "      <td>20.125000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>7.910400</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>50%</th>\n",
       "      <td>446.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>3.000000</td>\n",
       "      <td>28.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>14.454200</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>75%</th>\n",
       "      <td>668.500000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>3.000000</td>\n",
       "      <td>38.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>31.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>max</th>\n",
       "      <td>891.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>3.000000</td>\n",
       "      <td>80.000000</td>\n",
       "      <td>8.000000</td>\n",
       "      <td>6.000000</td>\n",
       "      <td>512.329200</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "       PassengerId    Survived      Pclass         Age       SibSp  \\\n",
       "count   891.000000  891.000000  891.000000  714.000000  891.000000   \n",
       "mean    446.000000    0.383838    2.308642   29.699118    0.523008   \n",
       "std     257.353842    0.486592    0.836071   14.526497    1.102743   \n",
       "min       1.000000    0.000000    1.000000    0.420000    0.000000   \n",
       "25%     223.500000    0.000000    2.000000   20.125000    0.000000   \n",
       "50%     446.000000    0.000000    3.000000   28.000000    0.000000   \n",
       "75%     668.500000    1.000000    3.000000   38.000000    1.000000   \n",
       "max     891.000000    1.000000    3.000000   80.000000    8.000000   \n",
       "\n",
       "            Parch        Fare  \n",
       "count  891.000000  891.000000  \n",
       "mean     0.381594   32.204208  \n",
       "std      0.806057   49.693429  \n",
       "min      0.000000    0.000000  \n",
       "25%      0.000000    7.910400  \n",
       "50%      0.000000   14.454200  \n",
       "75%      0.000000   31.000000  \n",
       "max      6.000000  512.329200  "
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Some statistical information about the data\n",
    "train.describe()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'pandas.core.frame.DataFrame'>\n",
      "RangeIndex: 891 entries, 0 to 890\n",
      "Data columns (total 12 columns):\n",
      "PassengerId    891 non-null int64\n",
      "Survived       891 non-null int64\n",
      "Pclass         891 non-null int64\n",
      "Name           891 non-null object\n",
      "Sex            891 non-null object\n",
      "Age            714 non-null float64\n",
      "SibSp          891 non-null int64\n",
      "Parch          891 non-null int64\n",
      "Ticket         891 non-null object\n",
      "Fare           891 non-null float64\n",
      "Cabin          204 non-null object\n",
      "Embarked       889 non-null object\n",
      "dtypes: float64(2), int64(5), object(5)\n",
      "memory usage: 83.6+ KB\n"
     ]
    }
   ],
   "source": [
    "# Checking if there are missing values in the dataset\n",
    "train.info()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Note: \n",
    "**There are missing values in the two columns:**\n",
    "- Age (177 missing values or 20%)\n",
    "- Cabin (687 missing values or 77%)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Exploring the data:\n",
    "- Bar chart of Survivors vs. non-survivors\n",
    "- Bar Chart of Survivors vs. non-survivors, by gender\n",
    "- Bar chat of survivors vs. non-survivors, by passenger class\n",
    "- A histogram of age distribution of passengers\n",
    "- Average age of passengers\n",
    "- Number of survivors, by age group\n",
    "- How many survived (or not) within specific age groups\n",
    "- Average age of passengers, by class\n",
    "- Number of people traveling with a passenger\n",
    "- Fares paid by various passengers"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Number of passengers in each class"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Number of class-1 passengers:  216\n",
      "Number of class-2 passengers:  184\n",
      "Number of class-3 passengers:  491\n"
     ]
    }
   ],
   "source": [
    "count = np.array([0, 0, 0])\n",
    "\n",
    "c1 = train[train['Pclass']==1]\n",
    "count[0] = len(c1)\n",
    "print('Number of class-1 passengers: ', count[0])\n",
    "\n",
    "c2 = train[train['Pclass']==2]\n",
    "count[1] = len(c2)\n",
    "print('Number of class-2 passengers: ', count[1])\n",
    "\n",
    "c3 = train[train['Pclass']==3]\n",
    "count[2] = len(c3)\n",
    "print('Number of class-3 passengers: ', count[2])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Text(0.5, 1.0, 'Passenger per Class')"
      ]
     },
     "execution_count": 33,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYUAAAEICAYAAACwDehOAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8vihELAAAACXBIWXMAAAsTAAALEwEAmpwYAAAXXUlEQVR4nO3de9RddX3n8fcnISAqEZBAIwGCGkYBR9RH8LKqI1K5aIXWUlHRWGnRkbbeHWB0ubpauhyn7XgDlYqadhSa1kGpVoXGC3aNigEZlVuJcosEEhAKCCKE7/yx97M9hCfJzmU/54G8X2uddfb+7dt3n+ycz7MvZ+9UFZIkAcwadwGSpJnDUJAkdQwFSVLHUJAkdQwFSVLHUJAkdQwFaRuT5Nokh427Ds1MhoKmTftldE+Su5LcnOTTSR477roeaZLMTfLBJNe3n/WKtn+3cdemmc9Q0HT77ap6LPBM4NnAe8Zcz2CSbDfd80+yPbAMOAA4ApgLPA+4FTh4yHr0yGAoaCyq6mfAV4ADk+yS5EtJ1iS5re1eMDluktcn+WmSO5Nck+Q1bfuTk3wryX8kuSXJP4xM85QkFyT5eZKrkvz+yLDPJDk9yZfbeX4vyZNGhr+kneY/kpzRLuMPR4a/IckVba1fS7LPyLBKclKSq4Gr113vJAvbcU5McmOSVUneMTJ8VpKTk/wkya1JlibZdZ1pT0hyPfD1KT7a1wF7A79TVZdX1QNVtbqq/ryq/mWKeg5O8p0kt7e1fLQNFtL4X0lWt5/FD5Mc2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2J7SFVtfCxJ0jZhph0+kiSNkaEgSeoYCkCS30hyTpKfJLk8yb8k2S/JwiQ/HmiZL0hySZL7k/zeEMvQ5hvTNvH2dlk/TLIsyXqvJdf0GtP28KYkP0pyaZJ/m667O2zzoZAkwLnAN6vqSVW1P3AqsMfAi74eeD3wuYGXo000xm3iB8BEVf1n4J+ADwy8PPUwxu3hc1X1tKo6iGZb+JuBlwcYCgAvAu6rqo9PNlTVpVX17dGR2r8Ivt3+dX9Jkue17fOTXNim+Y+T/GaS2Uk+0/b/KMnb1l1oVV1bVT8EHhh6BbXJxrVNfKOq7m57v0vzOx2N37i2hztGeh/DOj/kHcqMuiR1TA4ELu4x3mrgt6rql0kWAWcDE8Crga9V1WntDf0eDRwE7FlVBwIk2XmIwjWYmbBNnAB8ZfPK11Y2tu0hyUnA24HtgUO3cD16MRT6mwN8NMlBwFpgv7b9+8CnkswBvlBVlyb5KfDEJB8BvgycP46CNbhBtokkx9N8mbxwyOK11W317aGqTgdOT/Jq4D3A4oHXwcNHwGXAs3qM9zbgZuDpNP9htweoqguBFwA/A/4+yeuq6rZ2vG8CJwGf3Ppla0Bj2yaSHAb8d+DlVXXvlq2GtpKZ8B1xDnDMZtS+yQwF+DqwQ5I/mmxI8uwk6/6V9jhgVVU9ALyW5hfXtFeIrK6qvwXOAp6ZZDdgVlV9Hngv8MxpWA9tPWPZJpI8A/gETSCsHmC9tHnGtT0sGul9KXD1Vlyn9fIXzUCSJwAfpPlr4JfAtcBbgfuAL1XVge0/0OeBu4FvAH9SVY9Nshh4VzvuXcDrgLnAp/l16J5SVQ86Ppzk2TRXNOzSLvOmqjpguLXUphjTNvGvwNOAVW3T9VX18oFWUZtgTNvDh4DD2uluA/54Om77YyhIkjoePpIkdQwFSVLHUJAkdQwFSVLHUJAkdQwFSVLHUJAkdf4/SYjy9cBqwzoAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.bar(['Class-1', 'Class-2', 'Class-3'], [count[0], count[1], count[2]], width=0.3, color=\"blue\")\n",
    "plt.xticks(['Class-1', 'Class-2', 'Class-3'], ('Class 1', 'Class 2', 'Class 3'))\n",
    "plt.ylabel('Passengers')\n",
    "plt.title('Passenger per Class')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYsAAAD4CAYAAAAdIcpQAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8vihELAAAACXBIWXMAAAsTAAALEwEAmpwYAAAYp0lEQVR4nO3df3SU1b3v8fc3MZgjoajYWCAcg1xtgSBjgi2eYhpYB6lA7xGzbpe0KCiCHH8Brl5Xrete/NGqRT3gOqV1SfWKaKHXhXpdylFoEX+eVpI4aMQSxROaIIhwCvijYEi+9495khMsZA9hhoGZz2utZ2VmZ888e+8V8snezzMbc3dERES6kpfpBoiIyLFPYSEiIkEKCxERCVJYiIhIkMJCRESCTsh0A1LptNNO89LS0kw3Q0TkuFFbW7vD3b8aqpdVYVFaWkpNTU2mmyEictwws83J1NMylIiIBCksREQkSGEhIiJBCgsREQlSWIiISJDCQkREghQWIiISpLAQEZGgrPpQXm0tmGW6FSIiR8/R+i+JNLMQEZEghYWIiAQpLEREJEhhISIiQQoLEREJUliIiEiQwkJERIIUFiIiEqSwEBGRIIWFiIgEKSxERCRIYSEiIkEKCxERCVJYiIhIkMJCRESCFBYiIhKksBARkSCFhYiIBCksREQkSGEhIiJBCgsRkSzR2trKueeey8SJEwFYv349559/PsOGDeN73/see/bsAWDnzp2MHj2aoqIigL9P5r0VFiIiWeL+++9n8ODBHc+vuuoq7r77bt5++20mTZrEPffcA0BhYSF33HEH9957b9LvrbAQEckCzc3NPPfcc1x11VUdZRs3bqSyshK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N33nknH330UVrPO23aNJ5//vm0nkNhISKSIi+++CIFBQXMmjWroywWizFgwICO542NjVxwwQWUl5dTXl7O66+/DsDWrVuprKwkFotRVlbGK6+8QmtrK9OmTaOsrIxhw4axYMGCg563srKSU089Na19U1hITmtqamL06NEMHjyYoUOHcv/99wPwxBNPMHToUPLy8qipqTngNW+99Rbnn38+Q4cOZdiwYbqnXzrU19dTUVHRZZ3i4mJWr15NXV0dv/3tb7nhhhsA+M1vfsO4ceOIx+OsX7+eWCxGPB5ny5Yt1NfX8/bbb3PFFVccjW4clD5nITnthBNO4L777qO8vJxPPvmEiooKxo4dS1lZGU8++SRXX331AfX379/PlClTWLp0KcOHD2fnzp3d/pCT5KaWlhauu+464vE4+fn5NDQ0AHDeeedx5ZVX0tLSwsUXX0wsFuPMM8/kgw8+4Prrr2fChAlceOGFGWu3ZhaS0/r27Ut5eTkAvXr1YvDgwWzZsoXBgwfz9a9//W/qr1q1inPOOYfhw4cD0KdPH/Lz849qm+XYNXToUGpra7uss2DBAk4//XTWr19PTU0NX3zxBZBYSnr55Zfp378/l112GY8++iinnHIK69evp6qqikWLFnHVVVfR1NRELBYjFovxwAMPHI1uAQoLkQ6NjY28+eabfOtb3zpknYaGBsyMcePGUV5ezvz5849iC+VYN2bMGPbt28fixYs7ytatW8fmzZs7nu/evZu+ffuSl5fH0qVLaW1tBWDz5s0UFxczY8YMpk+fTl1dHTt27KCtrY3q6mruuOMO6urqGDBgAPF4nHg8fsC1kXRLKizM7GtmttzMNpnZBjNbaWZnm1l9uhpmZg+b2fZ0nkOk3aeffkp1dTULFy7kK1/5yiHr7d+/n1dffZXHH3+cV199laeeeorf//73R7GlcljcU3sEmBlPPfUUq1evZtCgQQwdOpRbb72Vfv36ddS55pprWLJkCSNHjqShoYGePXsCsHbtWmKxGOeeey4rVqxg9uzZbNmyhaqqKmKxGNOmTeOuu+466HknT57M+eefz8aNGykpKeGhhx5Kzfh15u5dHoAB/w7M6lQWAy4A6kOv7+4BVALlh3OOit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CYII=\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "classes = ['Class-1', 'Class-2', 'Class-3']\n",
    "colors = ['red', 'green', 'blue']\n",
    "for i, j, k in zip(classes, count, colors):\n",
    "    plt.barh(i, j, color = k, align = 'center', label = classes)\n",
    "\n",
    "plt.legend(['Class-1', 'Class-2', 'Class-3'], loc='best')\n",
    "\n",
    "for index, value in enumerate(count):\n",
    "    plt.text(value, index, str(value))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Counting the number of survivors and non-survivors"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "c= Counter({0: 549, 1: 342})\n",
      "Keys: [0, 1]\n",
      "Values: [549, 342]\n"
     ]
    }
   ],
   "source": [
    "from collections import Counter\n",
    "c = Counter(train['Survived'])\n",
    "print('c=', c)\n",
    "\n",
    "c_keys = list(c.keys())\n",
    "print('Keys:', c_keys)\n",
    "\n",
    "c_values = list(c.values())\n",
    "print('Values:', c_values)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## A Bar chart of survivors and non-survivors"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Text(0.5, 1.0, 'Survival')"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYUAAAEICAYAAACwDehOAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8vihELAAAACXBIWXMAAAsTAAALEwEAmpwYAAAWDElEQVR4nO3dfbRddX3n8ffHgOADIEjASIKhTpSCLVSu+IC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UJEkdQ0GS1DEUJEkdQ0GS1DEUJEkdQ0GS1DEUJEmd/w/X9+cZoE8EzQAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.bar(c_keys, c_values, width=0.3, color=\"blue\")\n",
    "plt.xticks(c_keys, ('Not Survived', 'Survived'))\n",
    "plt.ylabel('Passengers')\n",
    "plt.title('Survival')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Counting survivors vs. non-survivors, by *gender*"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Surviving males:  109 Non-surviving males: 468\n",
      "Surviving females:  233 Non-surviving females: 81\n"
     ]
    }
   ],
   "source": [
    "# Males\n",
    "sm  = train[(train['Survived']==1) & (train['Sex']=='male')]\n",
    "nsm = train[(train['Survived']==0) & (train['Sex']=='male')]\n",
    "\n",
    "# Females\n",
    "sf  = train[(train['Survived']==1) & (train['Sex']=='female')]\n",
    "nsf = train[(train['Survived']==0) & (train['Sex']=='female')]\n",
    "\n",
    "print('Surviving males: ', len(sm), 'Non-surviving males:', len(nsm))\n",
    "print('Surviving females: ', len(sf), 'Non-surviving females:', len(nsf))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Bar chart of survivors vs. non-survivors by gender"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYUAAAEICAYAAACwDehOAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8vihELAAAACXBIWXMAAAsTAAALEwEAmpwYAAAdY0lEQVR4nO3de5gU5Z328e8tjoL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ZwD9KaidpD5Jh1lbJodD8fQ4YK+k1SfNIfnxoJHAzcKek35N0nbfmUZIX/8StbDMBOJ9N/wF9E7hY0qvAAj77bYsRwGWSZgG1x5Btx/YjkttZ1xgOfCt97V5A8tqB5A35akmv1HGieSAwP33dPU1y7uE9kg8jbwN/Au4g6ZXUKe01TCH5wa4pW9hmAUkwLYuI5emyqSTDXTPTXvmjwB4R8TLJv425JMNUv6//qWiZfJsLMzPLuKdgZmYZh4KZmWUcCmZmlnEomJlZxqFgZmYZh4KZmWUcCmZmlvn/Y8asc8Xf6gUAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "males = (len(sm), len(nsm))\n",
    "females = (len(sf), len(nsf))\n",
    "       \n",
    "plt.bar([0, 1], males, width=0.3, label='Males')\n",
    "plt.bar([0.4, 1.4] , females, width=0.3, label='Females')\n",
    "\n",
    "plt.ylabel('Passengers')\n",
    "plt.title('Survival by Gender')\n",
    "plt.xticks([0.2,1.2], ('Survived', 'Not Survived'))\n",
    "plt.legend(loc='best')\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Breakdown of survivors vs. non-survivors by *class*"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [],
   "source": [
    "c1s = len(train[(train['Survived']==1) & (train['Pclass']==1)])\n",
    "c2s = len(train[(train['Survived']==1) & (train['Pclass']==2)])\n",
    "c3s = len(train[(train['Survived']==1) & (train['Pclass']==3)])\n",
    "\n",
    "c1ns = len(train[(train['Survived']==0) & (train['Pclass']==1)])\n",
    "c2ns = len(train[(train['Survived']==0) & (train['Pclass']==2)])\n",
    "c3ns = len(train[(train['Survived']==0) & (train['Pclass']==3)])"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Bar chart of survivors vs. non-survivors by *class*"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYUAAAEICAYAAACwDehOAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8vihELAAAACXBIWXMAAAsTAAALEwEAmpwYAAAgIElEQVR4nO3dfZxWdZ3/8ddbHAUVAXU07nTQhV2Rm0kGsNwIrR/gzQ8jJcY7cNciFVpyy5J+vx7pr+jhuratuWnhqpChgJFKqaWhhqYmDI4oIEHB5sQkiEgiijB+fn9cZ46XMMAFzJlrbt7Px2Mec53vufucOXq9Od9zp4jAzMwM4KBiF2BmZs2HQ8HMzFIOBTMzSzkUzMws5VAwM7OUQ8HMzFIOBWvTJP1I0jcbYTkzJH1nN+Muk/T0ga5jL+sfLqkmy3VY2+BQsGZH0j9KekbSZklvSPqdpMFZrCsiroiIb2exbLOW6OBiF2CWT9KRwC+BK4G5wCHAJ4Bt+7EsAYqI9xu1SLNWzEcK1tz0AYiIeyOiLiLeiYhHI2IpgKTrJP20fmJJZZJC0sHJ8JOSpkn6HbAV+IakxfkrkHS1pPnJ57TbR9IKSefmTXewpNclnZoM3yfpr8kRzEJJp+zDdknSLcm8r0j6VNI4VlLVThN+RdIDu1nIUZLukrRO0qY9THetpD9KekvScklj8sb9naTfJrW8LmlOfYGSvi9pfTJuqaR++7CN1go4FKy5+QNQJ2mmpLMkddmPZVwKTAQ6ArcAfy+pd974i4B7GpjvXuDCvOGRwOsRsSQZfgToDRwLLAFm7UNNQ4E/AccA3wJ+LukoYD7QS9LJedNeAty9m+XcDRwGnJLU8f3dTPdHckdYnYDrgZ9K6pqM+zbwKNAF6EHubwQwAhhGLpg7A+OAjfuwjdYKOBSsWYmIvwH/CARwO7BB0nxJx+3DYmZExLKI2BERm4EHSb7sk3D4B3Jfxju7Bxgt6bBk+EPhERF3RsRb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+wI4BCAiFgLDgL8Ad0saHxGbkumeBCYB/934ZVueou1DSZ8G/g8wOiK2HdhmtGnN4f/D2cBn9qP2onIoNL7HgUMlfaG+QdJgSTv/q68TUBsR7wOXkruDm+SKk/URcTtwB3CqpGOAgyJiHvBN4NQm2I62rCj7UNJHgR+TC4T1GWxXW1Ksfdg7b/AcYFUjblOT8B3NGZDUDfhPcv9SeRdYC3wZ2A78MiL6Jf/xzAO2Ak8AX4qIIyRNAK5Jpt0CjAeOBO7igxCfGhEf6m+WNJjc1RZdknX+NSJOyW4rW7ci7cPfAP2B2qTpzxExOqNNbPWKtA9vBj6dzLcJmNzSHtXjUDAzs5S7j8zMLOVQMDOzlEPBzMxSDgUzM0s5FMzMLOVQMDOzlEPBzMxS/x/F4Lt8MjHAVQAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "survived = (c1s, c2s, c3s)\n",
    "dead = (c1ns, c2ns, c3ns)\n",
    "\n",
    "plt.bar([0, 1, 2], survived, width=0.3, label='survived')\n",
    "plt.bar([0.4, 1.4, 2.4] , dead, width=0.3, label='not survived')\n",
    "\n",
    "plt.ylabel('Passengers')\n",
    "plt.title('Survival by class')\n",
    "plt.xticks([0.2,1.2, 2.2], ('Class 1', 'Class 2', 'Class 3'))\n",
    "plt.legend(loc='best')\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 57,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXoAAAD8CAYAAAB5Pm/hAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvOIA7rQAADt1JREFUeJzt3WuMXPV9xvHvUxxC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drIEx9hyLPqjusSCBpK8Gfga8PGq+tm48wBU1f/W4NfqNQwugnf2fJstZaYkHwAOVtXOuavn2XQcx9qFVXUeg+nKa5K8dwwZ5rMCOA+4parOBX7O+KaQXqGb674C+OtxZwHo3hO4EjgTeBtwAoPX9HAjP8aWY9Ef1SUWxuyFJKsAutuD4wiR5A0MSv6Oqrp3krIBVNWLwKMM3kNYmeTQeR3jeE0vBK5I8gPgLgbTN1+agFxU1fPd7UEGc83nMxmv435gf1Xt6Ja3MSj+ScgGgxJ9vKpe6JbHnev9wPeraraqXgLuBd7DEhxjy7Hol8MlFu4HNnb3NzKYH19SSQLcBuyuqi9MSrYkU0lWdvffxODg3w08AnxwXLmq6oaqWlNVaxkcU9+sqo+MO1eSE5K85dB9BnPOu5iAY6yqfgQ8l+Tt3aqLGVyOfOzZOh/ml9M2MP5c+4D1SY7v/n0e+nkt/jE2rjdJer6pcRnwzwzmdv90zFnuZDDf9hKDEc4mBnO724E93e1JY8i1gcGvgN8Bnuy+Lht3NuA3gSe6XLuAP+vWnwV8C9jL4FftN47xNX0f8OAk5Oqe/9vd11OHjvdxv45z8p0DzHSv598CJ05CNgZv9P8b8Otz1k1Crs8CT3fH/l8Bb1yKY8wzYyWpcctx6kaStAAWvSQ1zqKXpMZZ9JLUOItekhpn0UtS4yx6SWqcRS9Jjft/+3wNyIPbNr0AAAAASUVORK5CYII=\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Age Distribution: Histogram of 'Age'\n",
    "plt.hist(train['Age'].dropna(), bins=20, alpha=0.8)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 58,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "29.69911764705882"
      ]
     },
     "execution_count": 58,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# What is the mean age of the passengers?\n",
    "train['Age'].dropna().mean()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 59,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXoAAAD8CAYAAAB5Pm/hAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvOIA7rQAAFRBJREFUeJzt3X2MZXd93/H3Z3cxyZimfhpT4/XumGhFcF0ezIiagBDFIdgusq0KJKNRY1Gro4JFTJoKbFltGqlWQY2CiVSQJtjBKSMDdUhtWZTG2diCVMVk1g9gszh2YHc92Hgn2IaGlVIWf/vHPYNnl1nPztyns2feL+nq3PO75875ztwznznzO79zTqoKSVJ3bRl3AZKk4TLoJanjDHpJ6jiDXpI6zqCXpI4z6CWp4wx6Seo4g16SOs6gl6SO2zbuAgDOOOOMmpqaGncZknRC2bNnz99W1eRay7Ui6KemplhYWBh3GZJ0Qkmy/3iWs+tGkjrOoJekjjPoJanjDHpJ6jiDXpI6zqCXpI4z6CWp4wz6rpmfh6kp2LKlN52fH3dFksasFSdMaUDm52F2Fg4d6s3v39+bB5iZGV9dksbKPfouueGGF0J+2aFDvXZJm9aaQZ/kliQHkzy8ymv/LkklOaOZT5I/SPJ4km8kuWAYResYDhxYX7ukTeF49ug/A1x8dGOSc4B3ACtT5BJgV/OYBT7Vf4k6bjt2rK9d0qawZtBX1VeAZ1Z56ePAh4Fa0XY58MfV8zXglCRnDaRSre3GG2Fi4si2iYleu6RNa0N99EkuA75XVQ8d9dLZwBMr5hebNo3CzAzMzcHOnZD0pnNzHoiVNrl1j7pJMgHcAPz6ai+v0lartJFkll73DjvsWhicmRmDXdIRNrJH/8vAucBDSfYB24H7k/wjenvw56xYdjvw5GpfpKrmqmq6qqYnJ9e8br4kaYPWHfRV9c2qOrOqpqpqil64X1BV3wfuBH6j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B64b9R1NF0mDwIHgbuBvwGeq6rDzSKj+ExuovdL9Hwzf/oYagAo4M+S7Eky27SN8vN4JbAE/FHTjfXpJCePuIaVrgRua56PrIaq+h7we8AB4Cngh8AeRrtNPAy8NcnpSSaAS+ndT3ukn0VXgj6rtG2q4URJXgb8CfChqvrRqNdfVT+t3r/p2+n9m/rq1RYb1vqTvAs4WFV7VjaPsoYV3lxVF9DrSrwmyVtHsM6VtgEXAJ+qqtcDP2b4XUWravq/LwP++xjWfSpwOXAu8ArgZHqfydGGtk1U1V56XUV3A18GHqLX3TpSXQn6RXp/JZdtB54cUy1PJzkLoJkeHPYKk7yEXsjPV9UXx1UHQFU9B9xL73jBKUmWb1c57M/kzcBlSfYBn6PXfXPTiGsAoKqebKYH6fVLv5HRfh6LwGJV3dfM304v+MexTVwC3F9VTzfzo6zh14DvVtVSVf0E+CLwq4x4m6iqm6vqgqp6K/AM8Bgj/iy6EvR/BexqjqafRO9fxTvHVMudwFXN86vo9ZkPTZIANwN7q+r3x1FHkskkpzTPf5HeL9he4B7g3aOooaqur6rtVTVF7/P/i6qaGWUNAElOTvIPlp/T659+mBF+HlX1feCJJK9qmi4CvjXKGlZ4Ly902zDiGg4AFyaZaH5Pln8Oo94mzmymO4B/Qe/nMdrPYpgHAEb5oNf39df0+oZvGNE6b6PX9/cTentRV9PrF95N76/2buC0IdfwFnr/en4DeLB5XDrKOoDXAA80NTwM/Iem/ZXA14HH6f3r/tIRfS5vA+4aRw3N+h5qHo8sb4tj2C5eByw0n8n/AE4dQw0TwA+Af7iibdQ1/C7w7Wa7/G/AS8ewTXyV3h+Yh4CLxvFz8MxYSeq4rnTdSJKOwaCXpI4z6CWp4wx6Seo4g16SOs6gl6SOM+glqeMMeknquP8PZBTfMZpHZxcAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Define different age groups (0-10, 11-20, 21-30, ...) and\n",
    "# Count number of survivors within each age group\n",
    "\n",
    "df2 = train.dropna(subset=['Age'])\n",
    "\n",
    "s_groups = np.zeros(10)\n",
    "ns_groups = np.zeros(10)\n",
    "for i in range(len(df2)):\n",
    "    age_group = int(df2.iloc[i]['Age'] //10 )\n",
    "    if df2.iloc[i]['Survived']==1:\n",
    "        s_groups[age_group] += 1\n",
    "    else:\n",
    "         ns_groups[age_group] += 1   \n",
    "        \n",
    "x_val = pd.DataFrame(list(range(len(s_groups))))*10\n",
    "plt.scatter(x_val, s_groups, c='b')\n",
    "plt.scatter(x_val, ns_groups, c='r')\n",
    "plt.xticks(x_val)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 82,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "avg. age in class 1 38 \n",
      " avg. age in class 2 30 \n",
      " avg. age in class 3 25\n"
     ]
    }
   ],
   "source": [
    "# Find Average age per passenger class\n",
    "#age_in_class = np.zeros(3)\n",
    "age_in_class_1 = train[train['Pclass']==1]\n",
    "mean_class_1 = (age_in_class_1['Age'].dropna()).mean()\n",
    "\n",
    "age_in_class_2 = train[train['Pclass']==2]\n",
    "mean_class_2 = (age_in_class_2['Age'].dropna()).mean()\n",
    "\n",
    "age_in_class_3 = train[train['Pclass']==3]\n",
    "mean_class_3 = (age_in_class_3['Age'].dropna()).mean()\n",
    "\n",
    "print('avg. age in class 1',round(mean_class_1), '\\n', \\\n",
    "      'avg. age in class 2',round(mean_class_2), '\\n',\n",
    "      'avg. age in class 3',round(mean_class_3))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 85,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Counter({0: 608, 1: 209, 2: 28, 4: 18, 3: 16, 8: 7, 5: 5})\n"
     ]
    }
   ],
   "source": [
    "# Number of people traveling with a passenger\n",
    "\n",
    "c = Counter(train['SibSp'])\n",
    "print(c)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 94,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[(0, 608), (1, 209), (2, 28), (4, 18), (3, 16), (8, 7), (5, 5)]\n"
     ]
    }
   ],
   "source": [
    "y = c.most_common()\n",
    "print(y)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 98,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<BarContainer object of 7 artists>"
      ]
     },
     "execution_count": 98,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXoAAAD8CAYAAAB5Pm/hAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvOIA7rQAAD5BJREFUeJzt3X+s3XV9x/HnaxT8gc6CXAhrm10WG6MxEcgNdiMxkzrHD2P5wyaYTTrSpf8wh9NEq/8sJvsDk0UcyULSiLNsTiUooRHibPgRYzLQW6j8sBo6xuhdO3odUHVEHfreH+dz3bVcuOe25/ZcPn0+kpPv9/v+fs75vs9t+rrffs73e5qqQpLUr98adwOSpOVl0EtS5wx6SeqcQS9JnTPoJalzBr0kdc6gl6TOGfSS1DmDXpI6t2rcDQCcddZZNTk5Oe42JOkVZc+ePT+qqonFxq2IoJ+cnGR6enrcbUjSK0qS/xhmnFM3ktQ5g16SOmfQS1LnDHpJ6pxBL0mdM+glqXMGvSR1zqCXpM4NFfRJVie5LckPkuxL8vtJzkyyO8njbXlGG5skNybZn+ThJBcu71uQJL2cYe+M/TvgG1X1/iSnAa8FPgncXVXXJ9kObAc+DlwGrG+PdwA3teWymNx+53K99IKevP6KE3o8STpei57RJ/lt4J3AzQBV9Yuqeg7YBOxsw3YCV7b1TcAtNXA/sDrJuSPvXJI0lGGmb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AQ8CRqvrmOHph8Mvum0n2tLvb9QpwMgZ9Fqh56RGQ5HXAV4EPV9WPx3D89wKHq2rPiT72Qqrql1V1PoO7uy9K8rZx9JHkDAb/6jwP+B3g9CR/Oo5egIur6kIGU5/XJnnnmPrQEpyMQT/UVzScbJKcyiDkv1hVXxtTGxcD70vyJIMptUuS/NOYevm1qnoOuI/xfZ7ybuDfq2q2qv4X+BrwB+NopKoOtuVh4HYGU6Fa4U7GoPcrGo6SJMDNwL6q+sy4+qiqT1TV2qqaZPDnck9VjeXMNclEktVt/TUMwvYH4+iFwZTNhiSvbX9WGxnDh9VJTk/y+rl14D3AWK8Y03BOuqCvqheAua9o2AfcOq6vaEjyJeBfgTcnmUmydRx9MDiT/iCDM+i97XH5mHpZKc4F7k3yMIOTg91VNZbLPdtnA7cBDwKPMPh7O447U88Bvp3ke8B3gDur6htj6ENL5J2xktS5k+6MXpJONga9JHXOoJekzhn0ktQ5g16SOmfQS1LnDHpJ6pxBL0md+z8ydPwOsfrWBgAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "sib_list = []; count_list = []\n",
    "for elem in y:\n",
    "    sib, count = elem\n",
    "    sib_list.append(sib)\n",
    "    count_list.append(count)\n",
    "\n",
    "plt.xticks(range(len(sib_list)), sib_list)\n",
    "plt.bar(sib_list, count_list)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 419,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXEAAAD3CAYAAADrGWTVAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAD6pJREFUeJzt3W+oZPddx/H37N7dJqvLZqubRqxYivSHqFhswYqmWUoa\njLCs9IH4oLZx9UFhxQoLasr2gaASH2xALYKmrbGiIKaWJWBsaRNq8A9oiGAw/RVrRVSQa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0uewfyImFyqmF5WzDX+2sb9bU9cPq+Cthh+Cuc+m1a1tFnhFqesmu7feuh0Hb/dmmqqTpC\n69J3vfqT81hNI9MhrwDGHrdjtnuRcaP3sr9v6VinPrCpb9+23ZTZQO4Yt54y2QX+g9nZhx8AvpfZ\n4/IOijMUwCeABymyssvaQjyldAeQcs5PVRZ/mVko/wuzO+NLzHaoHElOme30m4pad9m7IX6m1kXT\ngVY+g8670esju1KfEcfL3DoKXYbqSGRZbVa13d/1/sYcGztz2inVT6OUT8pN91vbE2P9urZamwJu\nXvv12ufdv19vaRP29qeppo2ijfr685T9Dnkpv4imkfCQY3Fspow53k8x7lUyvP5V15AnkfqTff2J\npHpcHwPuZDZQfRbYZBbUN5llyFPFdS8DX2OWiZ8HbvT9eu91jsTfDXyhtuwSs5cWdzHbue9k9uz1\neW49h/kKswO/vHGOMXu2qj6Yqg/w6h1SntaYd5D02f+mB9kxbn2J3nS+uetccVNfL8xpa1nKJ8e2\nduv7Xf276eBve0CVoV11vKWGtldIQx7wJ5h/H847ddJn5H2qaLNJn2PqTOVyW4iXddxe+XtebfV6\nml7h9LkP5ylv76Z2Fzk+F3m107VNfV6q+mRYDgj7+t+GduD1x9IOszAub+8XmA0mv4/ZiPsU8FZm\nrw7fWNR5vGj3v4GzwBN9C1vnv2dLzEbcVZ8Afq64rnqA/mRlnbLG6oEPsztg3oNpyB3TZ92mB2W1\n77bR/NhRzDd1tL+IrvPX9Vrqfzedlx5TZ1Pwjz0n27etee31uc+W/Zhpa6+pvrFt9rkPx7S7yPG5\nyKvZrm3q73q7vXJ56G1bzZ/66cr6thvAd7M3EL2dvdt+o/j5NmYToO9n70ngHLNceYrXZ2UjP3Yv\nSYH5fmtJCswQl6TADHFJCswQl6TADHFJCswQl6TADHFJCuz/ASuHWixwYxDwAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x1fa3af7f828>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# The fare paid by different passengers\n",
    "\n",
    "c2 = Counter(train['Fare'])\n",
    "plt.bar(range(len(c2)), list(c2.values()), align='center')\n",
    "plt.xticks(range(len(c2)), list(c2.keys()))\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 449,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAsMAAAF0CAYAAADGqzQSAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzt3X2YXWV57/HvhMGk2CFN6xypLy32KLdcV0UpFNGIRLQi\nKgffqj29xJcoYKUFRK1o4KK1IGgF26BiTYyIl1aPYASjKHpQCHgUja/04A1oqVqPp9ETSDQlEpjz\nx1qD0+kkk5nsvZ5Fnu/nH2bW3jP3b/aQvX+z9lrPGpmYmECSJEmq0YLSASRJkqRSLMOSJEmqlmVY\nkiRJ1bIMS5IkqVqWYUmSJFVrtOTwjRu33G+WsliyZB82bdpadYbS8/uQofb5fchQ+/w+ZCg9vw8Z\nap/fhwyl5/chQ+3z52p8fGxkpu3uGd5Fo6N7lY5QPEPp+X3IUPv8PmSofX4fMpSe34cMtc/vQ4bS\n8/uQofb5g2IZliRJUrUsw5IkSaqWZViSJEnVsgxLkiSpWpZhSZIkVcsyLEmSpGpZhiVJklQty7Ak\nSZKqZRmWJElStWa9HHNE7AWsAgKYAF4F7A2sA25t73ZxZn40Ik4ATgK2A+dk5rqhpJYkSZIGYNYy\nDBwLkJlLI2IZcC7wSeDCzLxg8k4RsR9wCnAosAi4PiI+l5nbBp5akiRJGoCRiYmJWe8UEaOZuT0i\nXgocBWyl2VM8SrN3+DTgKcAzM/NV7desBd6SmV/d0ffdvv2eiT3lutaSJEnqtZGZNu7KnmHaIvwB\n4LnAC4CHAqszc0NErADOBr4J3Dnly7YAi3f2fTdt2ror43thfHyMjRu3VJ2h9Pw+ZKh9fh8y1D6/\nDxlKz+9Dhtrn9yFD6fl9yFD7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0lRWa36yamwAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x1fa3ad74128>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Fares paid by various passengers\n",
    "\n",
    "fdict = {}\n",
    "\n",
    "ls = np.linspace(0, 100, 20)\n",
    "for i in range(10):\n",
    "    val = len(list(x for x in train['Fare'] if ls[i] <= x <= ls[i+1]))\n",
    "    fdict[round(ls[i+1],0)] = round(val,0);\n",
    "\n",
    "ls = np.linspace(27.01, 270, 20)\n",
    "for i in range(10):\n",
    "    val = len(list(x for x in train['Fare'] if ls[i] <= x <= ls[i+1]))\n",
    "    fdict[round(ls[i+1],0)] = round(val,0)\n",
    "\n",
    "plt.figure(figsize=(12, 6))\n",
    "plt.bar(range(len(fdict)), list(fdict.values()), align='center')\n",
    "plt.xticks(range(len(fdict)), list(fdict.keys()))\n",
    "plt.xticks(rotation=90)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 451,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.axes._subplots.AxesSubplot at 0x1fa3acbb4e0>"
      ]
     },
     "execution_count": 451,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAeQAAAD4CAYAAAA9zZWtAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAEb9JREFUeJzt3GGIHPd5x/HvSWfrIlgdV1hbpIT4RZoHvVEaZJS0qmpB\nEjsuBDUm5EWJm8ZUlotBNg3EjSVjKDImJVZBDknKOY5StwZjxQqpwI0CTWxZpZWj2FAR8zgKCYSW\n4Is56S5WdbWk64udazfKaXc1t6f9a+/7AcHsf2Znnnt00m/+O7MzMj8/jyRJGqxVgy5AkiQZyJIk\nFcFAliSpAAayJEkFMJAlSSqAgSxJUgFGu20QEauBSSCAeeAe4DrgMPDjarOvZOYzEbED2Am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pm/yszZiGgAB2nN9OxfjzLzfER8A3gc\n+EfsXU8i4s+Aqcz8TtuwvevNWVonM7fRukxS/O/dsASyj+ys52LbcoPWzOXSXi6Mr3gR8S7ge8BT\nmfk09u+KZOangffSup78jrZV9u7y7qL1sKXvA78L/D1wQ9t6e3d5rwP/kJnzmfk68CZwY9v64no3\nLIHsIzvreSUitlXLtwNHgePA1ogYi4hxYAOtmx9WtIi4ETgCPJCZT1bD9q8HEXFnRHy+enmW1onM\nD+xdd5n5h5l5S2ZuA14F/hR43t715C6q+4ki4p20ZsJHSu7dsHys6yM76/ksMBkR1wOvAQcz80JE\n7Kf1i7oK2J2Z5wZZZCEeBCaAhyJi4VryfcB++9fVc8DXI+JF4Drgflr98nevHv/d9uZrwIGIeInW\nXdV3Ab+k4N756ExJkgowLB9ZS5J0TTOQJUkqgIEsSVIBDGRJkgpgIEuSVAADWZKkAhjIkiQV4H8B\nFa06XrbLGC8AAAAASUVORK5CYII=\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x1fa3ac97f60>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "train['Fare'].hist(color='red',bins=50,figsize=(8,4))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Imputing the missing data in the 'Age' column\n",
    "- find the mean age for each passenger class\n",
    "- Impute the age missing data using these computed values"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 397,
   "metadata": {},
   "outputs": [],
   "source": [
    "def compute_average_age_by_class():\n",
    "    a1 = train[train['Pclass']==1]['Age'].mean()\n",
    "    a2 = train[train['Pclass']==2]['Age'].mean()\n",
    "    a3 = train[train['Pclass']==3]['Age'].mean()\n",
    "    return a1, a2, a3"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 398,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "def impute_age(cols):\n",
    "    a1, a2, a3 = compute_average_age_by_class()\n",
    "    Age = cols[0]\n",
    "    Pclass = cols[1]\n",
    "    \n",
    "    if pd.isnull(Age):\n",
    "        if Pclass == 1:\n",
    "            return a1\n",
    "        elif Pclass == 2:\n",
    "            return a2\n",
    "        else:\n",
    "            return a3\n",
    "    else:\n",
    "        return Age"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 399,
   "metadata": {},
   "outputs": [],
   "source": [
    "train['Age'] = train[['Age','Pclass']].apply(impute_age,axis=1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 400,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'pandas.core.frame.DataFrame'>\n",
      "RangeIndex: 891 entries, 0 to 890\n",
      "Data columns (total 12 columns):\n",
      "PassengerId    891 non-null int64\n",
      "Survived       891 non-null int64\n",
      "Pclass         891 non-null int64\n",
      "Name           891 non-null object\n",
      "Sex            891 non-null object\n",
      "Age            891 non-null float64\n",
      "SibSp          891 non-null int64\n",
      "Parch          891 non-null int64\n",
      "Ticket         891 non-null object\n",
      "Fare           891 non-null float64\n",
      "Cabin          204 non-null object\n",
      "Embarked       889 non-null object\n",
      "dtypes: float64(2), int64(5), object(5)\n",
      "memory usage: 83.6+ KB\n"
     ]
    }
   ],
   "source": [
    "train.info()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 401,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "train.drop('Cabin',axis=1,inplace=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 402,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'pandas.core.frame.DataFrame'>\n",
      "RangeIndex: 891 entries, 0 to 890\n",
      "Data columns (total 11 columns):\n",
      "PassengerId    891 non-null int64\n",
      "Survived       891 non-null int64\n",
      "Pclass         891 non-null int64\n",
      "Name           891 non-null object\n",
      "Sex            891 non-null object\n",
      "Age            891 non-null float64\n",
      "SibSp          891 non-null int64\n",
      "Parch          891 non-null int64\n",
      "Ticket         891 non-null object\n",
      "Fare           891 non-null float64\n",
      "Embarked       889 non-null object\n",
      "dtypes: float64(2), int64(5), object(4)\n",
      "memory usage: 76.6+ KB\n"
     ]
    }
   ],
   "source": [
    "train.info()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 403,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'pandas.core.frame.DataFrame'>\n",
      "Int64Index: 889 entries, 0 to 890\n",
      "Data columns (total 11 columns):\n",
      "PassengerId    889 non-null int64\n",
      "Survived       889 non-null int64\n",
      "Pclass         889 non-null int64\n",
      "Name           889 non-null object\n",
      "Sex            889 non-null object\n",
      "Age            889 non-null float64\n",
      "SibSp          889 non-null int64\n",
      "Parch          889 non-null int64\n",
      "Ticket         889 non-null object\n",
      "Fare           889 non-null float64\n",
      "Embarked       889 non-null object\n",
      "dtypes: float64(2), int64(5), object(4)\n",
      "memory usage: 83.3+ KB\n"
     ]
    }
   ],
   "source": [
    "train.dropna(inplace=True)\n",
    "train.info()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 404,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "sex = pd.get_dummies(train['Sex'],drop_first=True)\n",
    "embark = pd.get_dummies(train['Embarked'],drop_first=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 405,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "train.drop(['Sex','Embarked','Name','Ticket'],axis=1,inplace=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 406,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style>\n",
       "    .dataframe thead tr:only-child th {\n",
       "        text-align: right;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: left;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>PassengerId</th>\n",
       "      <th>Survived</th>\n",
       "      <th>Pclass</th>\n",
       "      <th>Age</th>\n",
       "      <th>SibSp</th>\n",
       "      <th>Parch</th>\n",
       "      <th>Fare</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>3</td>\n",
       "      <td>22.0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>7.2500</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>38.0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>71.2833</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   PassengerId  Survived  Pclass   Age  SibSp  Parch     Fare\n",
       "0            1         0       3  22.0      1      0   7.2500\n",
       "1            2         1       1  38.0      1      0  71.2833"
      ]
     },
     "execution_count": 406,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "train.head(2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 407,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style>\n",
       "    .dataframe thead tr:only-child th {\n",
       "        text-align: right;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: left;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>PassengerId</th>\n",
       "      <th>Survived</th>\n",
       "      <th>Pclass</th>\n",
       "      <th>Age</th>\n",
       "      <th>SibSp</th>\n",
       "      <th>Parch</th>\n",
       "      <th>Fare</th>\n",
       "      <th>male</th>\n",
       "      <th>Q</th>\n",
       "      <th>S</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>3</td>\n",
       "      <td>22.0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>7.2500</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>38.0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>71.2833</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   PassengerId  Survived  Pclass   Age  SibSp  Parch     Fare  male  Q  S\n",
       "0            1         0       3  22.0      1      0   7.2500     1  0  1\n",
       "1            2         1       1  38.0      1      0  71.2833     0  0  0"
      ]
     },
     "execution_count": 407,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "train = pd.concat([train,sex,embark],axis=1)\n",
    "train.head(2)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Using Logistic Regression"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 408,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "from sklearn.linear_model import LogisticRegression"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 409,
   "metadata": {},
   "outputs": [],
   "source": [
    "X = train.drop('Survived',axis=1)\n",
    "y = train['Survived']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 410,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "LogisticRegression(C=1.0, class_weight=None, dual=False, fit_intercept=True,\n",
       "          intercept_scaling=1, max_iter=100, multi_class='ovr', n_jobs=1,\n",
       "          penalty='l2', random_state=None, solver='liblinear', tol=0.0001,\n",
       "          verbose=0, warm_start=False)"
      ]
     },
     "execution_count": 410,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "logmodel = LogisticRegression()\n",
    "logmodel.fit(X,y)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 411,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "from sklearn.model_selection import train_test_split\n",
    "X_train, X_test, y_train, y_test = train_test_split(\n",
    "    X, y, test_size=0.30, random_state=97)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 412,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "predictions = logmodel.predict(X_test)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 413,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "             precision    recall  f1-score   support\n",
      "\n",
      "          0       0.82      0.88      0.85       173\n",
      "          1       0.74      0.64      0.69        94\n",
      "\n",
      "avg / total       0.79      0.79      0.79       267\n",
      "\n"
     ]
    }
   ],
   "source": [
    "from sklearn.metrics import classification_report\n",
    "print(classification_report(y_test, predictions))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Using Test Data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 414,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'pandas.core.frame.DataFrame'>\n",
      "RangeIndex: 418 entries, 0 to 417\n",
      "Data columns (total 11 columns):\n",
      "PassengerId    418 non-null int64\n",
      "Pclass         418 non-null int64\n",
      "Name           418 non-null object\n",
      "Sex            418 non-null object\n",
      "Age            332 non-null float64\n",
      "SibSp          418 non-null int64\n",
      "Parch          418 non-null int64\n",
      "Ticket         418 non-null object\n",
      "Fare           417 non-null float64\n",
      "Cabin          91 non-null object\n",
      "Embarked       418 non-null object\n",
      "dtypes: float64(2), int64(4), object(5)\n",
      "memory usage: 36.0+ KB\n"
     ]
    }
   ],
   "source": [
    "# read training data into a dataframe\n",
    "test = pd.read_csv('titanic_test.csv')\n",
    "\n",
    "test.info()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 415,
   "metadata": {},
   "outputs": [],
   "source": [
    "test['Age'] = test[['Age','Pclass']].apply(impute_age,axis=1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 416,
   "metadata": {},
   "outputs": [],
   "source": [
    "test.drop('Cabin',axis=1,inplace=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 417,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'pandas.core.frame.DataFrame'>\n",
      "Int64Index: 417 entries, 0 to 417\n",
      "Data columns (total 9 columns):\n",
      "PassengerId    417 non-null int64\n",
      "Pclass         417 non-null int64\n",
      "Age            417 non-null float64\n",
      "SibSp          417 non-null int64\n",
      "Parch          417 non-null int64\n",
      "Fare           417 non-null float64\n",
      "male           417 non-null uint8\n",
      "Q              417 non-null uint8\n",
      "S              417 non-null uint8\n",
      "dtypes: float64(2), int64(4), uint8(3)\n",
      "memory usage: 24.0 KB\n",
      "None\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style>\n",
       "    .dataframe thead tr:only-child th {\n",
       "        text-align: right;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: left;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>PassengerId</th>\n",
       "      <th>Pclass</th>\n",
       "      <th>Age</th>\n",
       "      <th>SibSp</th>\n",
       "      <th>Parch</th>\n",
       "      <th>Fare</th>\n",
       "      <th>male</th>\n",
       "      <th>Q</th>\n",
       "      <th>S</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>892</td>\n",
       "      <td>3</td>\n",
       "      <td>34.5</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>7.8292</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>893</td>\n",
       "      <td>3</td>\n",
       "      <td>47.0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>7.0000</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   PassengerId  Pclass   Age  SibSp  Parch    Fare  male  Q  S\n",
       "0          892       3  34.5      0      0  7.8292     1  1  0\n",
       "1          893       3  47.0      1      0  7.0000     0  0  1"
      ]
     },
     "execution_count": 417,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "test.dropna(inplace=True)\n",
    "sex = pd.get_dummies(test['Sex'],drop_first=True)\n",
    "embark = pd.get_dummies(test['Embarked'],drop_first=True)\n",
    "test.drop(['Sex','Embarked','Name','Ticket'],axis=1,inplace=True)\n",
    "test = pd.concat([test,sex,embark],axis=1)\n",
    "print(test.info())\n",
    "test.head(2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 418,
   "metadata": {},
   "outputs": [],
   "source": [
    "#X_test = test.drop('Survived',axis=1)\n",
    "#y_test = test['Survived']\n",
    "\n",
    "predictions = logmodel.predict(test)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Can we consider \"Title\" from the name, Cabin letter, Ticket as a feature?"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
